package org.wzl.databasesync.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzl.databasesync.dto.SyncSqlDTO;
import org.wzl.databasesync.dto.SyncSqlResp;
import org.wzl.databasesync.service.DatabaseSyncService;
import org.wzl.databasesync.utils.Resp;

@Slf4j
@RestController
@RequestMapping("/databaseSync")
public class DatabaseSyncController {

    @Resource
    private DatabaseSyncService databaseSyncService;

    @PostMapping("/syncSql")
    public Resp<SyncSqlResp> syncSql(@RequestBody SyncSqlDTO syncSqlDTO) {
        try {
            return Resp.ok(databaseSyncService.syncSql(syncSqlDTO));
        } catch (Exception e) {
            return Resp.fail("同步失败");
        }
    }


}
